" Vim syntax file
" Language:	NASL
" Maintainer:	Henri Doreau <henri.doreau@greenbonet.net>
" Version:	$Revision: 11 $
" Last Change:	$Date: 2011-10-21 15:35:20 +0000 (Fri, 21 Oct 2011) $
" URL: http://code.google.com/p/naslvim


" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

syntax sync minlines=100 maxlines=500

syn keyword naslStatement	break return continue exit
syn keyword naslRepeat		for while foreach repeat until
syn keyword naslConditional	if else
syn keyword naslStatement	function nextgroup=naslFunction skipwhite
syn match   naslFunction	"[a-zA-Z_][a-zA-Z0-9_]*" contained

syn keyword naslScope		local_var global_var
syn keyword naslPreCondit	description include
syn keyword naslConstant	NULL TRUE FALSE

syn match   naslComment		"#.*$" contains=naslTodo,@Spell
syn keyword naslTodo		TODO FIXME XXX contained

" strings
syn region naslString		start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=naslEscape,@Spell
syn region naslString		start=+L\='+ skip=+\\\\\|\\'+ end=+'+ contains=naslEscape,@Spell
syn match  naslNumber		"-\=\<\d\+\>#\="
syn match  naslEscape		+\\[abfnrtv'"\\]+ contained
syn match  naslEscape		"\\\o\{1,3}" contained
syn match  naslEscape		"\\x\x\{2}" contained
syn match  naslEscape		"\(\\u\x\{4}\|\\U\x\{8}\)" contained
syn match  naslEscape		"\\$"
syn case ignore
syn keyword naslTodo		contained todo
syn case match


syn keyword naslBuiltin		script_id script_version script_tag script_name
syn keyword naslBuiltin		script_description script_summary script_category
syn keyword naslBuiltin		script_copyright script_family script_dependencies
syn keyword naslBuiltin		script_xref script_cve_id script_require_keys
syn keyword naslBuiltin		script_bugtraq_id script_require_ports script_timeout
syn keyword naslBuiltin		script_exclude_keys script_require_udp_ports
syn keyword naslBuiltin		script_add_preference script_dependencie script_oid
syn keyword naslBuiltin		script_mandatory_keys


" some common functions
syn keyword naslBuiltin		get_kb_item set_kb_item get_kb_list replace_kb_item


" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_nasl_syntax_inits")
  if version < 508
	let did_nasl_syntax_inits = 1
	command -nargs=+ HiLink hi link <args>
  else
	command -nargs=+ HiLink hi def link <args>
  endif

  HiLink naslStatement		Statement
  HiLink naslRepeat		Repeat
  HiLink naslConditional	Conditional
  HiLink naslFunction		Function
  HiLink naslScope		type
  HiLink naslPreCondit		PreCondit
  HiLink naslConstant		Constant
  HiLink naslComment		Comment
  HiLink naslTodo		Todo
  HiLink naslString		String
  HiLink naslNumber		Number
  HiLink naslEscape		Special
  HiLink naslBuiltin	    	Function

  delcommand HiLink
endif

let b:current_syntax = "nasl"

" vim ts=8

